SPB Git
1.6 KB · 22 lines tsx
1import type { Metadata } from "next";2import { notFound } from "next/navigation";3import { getLocale } from "@/lib/i18n/server";4import { t } from "@/lib/i18n";5import { getTopic, listPapers } from "@/lib/papers/queries";6import { PaperRow } from "@/components/paper-items";7export const revalidate = 300;8export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> { const { slug } = await params; const x = await getTopic(slug); const locale = await getLocale(); return x ? { title: locale === "fr" ? x.name_fr : x.name_en, description: (locale === "fr" ? x.description_fr : x.description_en) ?? undefined, alternates: { canonical: `/topics/${slug}` } } : {}; }9export default async function TopicPage({ params }: { params: Promise<{ slug: string }> }) {10  const { slug } = await params; const locale = await getLocale(); const d = t(locale); const x = await getTopic(slug); if (!x) notFound();11  const res = await listPapers({ topic: [slug], sort: "recent", perPage: 100 });12  return (13    <div className="container py-10">14      <p className="kicker">{x.kind === "domain" ? d.paper.domain : d.papers.topic}</p>15      <h1 className="text-3xl sm:text-4xl mt-2">{locale === "fr" ? x.name_fr : x.name_en}</h1>16      {(locale === "fr" ? x.description_fr : x.description_en) && <p className="meta mt-2 max-w-3xl">{locale === "fr" ? x.description_fr : x.description_en}</p>}17      <p className="meta mt-3">{res.total} {res.total === 1 ? d.topics.paper : d.topics.papers}</p>18      <div className="card px-5 mt-6">{res.items.map((p) => <PaperRow key={p.id} p={p} locale={locale} />)}</div>19    </div>20  );21}22
Files · ef2aafa50a0de3a6025a4230d5261ba6d89d122c
Menu

Theme